﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lidgren.Network;

namespace D2D2.SharedInterfaces.Networking
{
    public abstract class BaseMessage : IGameMessage
    {
        protected BaseMessage()
        {
            
        }

        protected BaseMessage(NetIncomingMessage message)
        {
            MessageTime = message.ReadTime(false);
            Decode(message);
        }

        protected BaseMessage(NetIncomingMessage message, NetConnection connection)
        {
            MessageTime = message.ReadTime(connection, false);
            Decode(message);
        }

        public double MessageTime { get; set; }

        public abstract GameMessageType MessageType { get; }
        public long Id { get; set; }
        public double LocalTime { get; set; }

        public abstract void Encode(NetOutgoingMessage message);

        public abstract void Decode(NetIncomingMessage message);
    }
}
